﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace System
{
    internal static class EnumExtension
    {
        public static int GetEnumValueFromName(this Type enumType, string enumName)
        {
            return Enum.GetValues(enumType).Cast<object>().Where(v => v.ToString() == enumName).Select(v => (int)v).First();
        }

        public static object GetEnumValueFromInt(this Type enumType, int value)
        {
            return Enum.GetValues(enumType).Cast<object>().Where(v => (int)v == value).FirstOrDefault();
        }
    }
}
